<?php

/*
 *  Action $6
 * 
 *  +1 Cards, +2 Actions
 * 
 *  When you gain this, gain a card costing less then this
 * 
 */

class BorderVillage extends Card implements iAction, iKingdom, iHinterlands {
    
    public function __construct() {
        parent::__construct("Border Village", 6);
    }
    
    public function getDescription() {
        return array(
            "+1 Cards",
            "+2 Actions",
            "When you gain this, gain a card costing less then this");
    }
    
    public function play(Game $game) {
        $game->addActions(2);
        $drawed_cards = $game->drawCards(1);
        ScreenDisplay::addScreenMessage($game, true, "get +2 action and draw " . nicePrint($drawed_cards), "gets +2 action and draws ".sizeof($drawed_cards). "cards");
    }
    
    public function gainThisCard(Game $game, $name = null) {
        $price = $this->getPrice($game);
        $new_price = $price->add(-1);
        $optional_cards = $game->getBoardCardsByPrice(null, $new_price);
        if (sizeof($optional_cards) > 0) {
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $optional_cards, 1, 1, null, "Choose card to gain", $name);
            $card_name = $output[0];
            $card = $game->moveCardFromPileToPile($card_name, BoardCards, DiscardPile, $name);
             ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($card), "gains " .ScreenDisplay::$LMSG, $name);
        }
        $game->setTempCard($this);
        return true;
    }
}
?>